// 模拟后端动态生成路由
import component from "element-plus/es/components/tree-select/src/tree-select-option.mjs";
import { defineFakeRoute } from "vite-plugin-fake-server/client";
// import { system, monitor, permission, frame, tabs } from "@/router/enums";

/**
 * roles：页面级别权限，这里模拟二种 "admin"、"common"
 * admin：管理员角色
 * common：普通角色
 */

const permissionRouter = {
  path: "/permission",
  name: "permission",
  meta: {
    title: "权限管理",
    icon: "ep:lollipop",
    rank: 10,
    roles: ["admin"],
  },
  children: [
    {
      path: "/permission/page/index",
      name: "pagePermission",
      meta: {
        title: "页面权限",
        roles: ["admin", "common"],
      },
    },
    {
      path: "/permission/button",
      name: "buttonPermission",
      meta: {
        title: "按钮权限",
        roles: ["admin", "common"],
      },
      children: [
        {
          path: "/permission/button/router",
          component: "permission/button/router",
          name: "permissionButtonRouter",
          meta: {
            title: "路由返回按钮权限",
            auths: [
              "permission:btn:add",
              "permission:btn:edit",
              "permission:btn:delete",
            ],
            roles: ["admin", "common"],
          },
        },
        {
          path: "/permission/button/login",
          component: "permission/button/perms",
          name: "permissionButtonLogin",
          meta: {
            title: "登录接口返回按钮权限",
            roles: ["admin", "common"],
          },
        },
      ],
    },
  ],
};

const componentsRouter = {
  path: "/showComponents",
  name: "showComponents",
  meta: {
    title: "组件",
    rank: 11,
    role:["admin"]
  },
  children: [
    {
      path: "/messageHint",
      name: "messageHint",
      meta: {
        title: "消息提示",
        roles: ["admin"],
      },
    },
    {
      path: "/filesUpload",
      name: "filesUpload",
      meta: {
        title: "文件上传",
        roles: ["admin"],
      },
    },
    {
      path: "/virtualList",
      name: "virtualList",
      meta: {
        title: "虚拟列表",
        roles: ["admin"],
      },
    },
    {
      path: "/functionAlert",
      name: "functionAlert",
      meta: {
        title: "函数式弹框",
        roles: ["admin"],
      },
    },
  ],
};

const moreMenus = {
  path: "/listTest",
  name: "listTest",
  meta: {
    title: "菜单",
    icon: "ep:lollipop",
    rank: 12,
    roles: ["admin", "common"],
  },
  children: [
    {
      path: "/listIn1",
      name: "listIn1",
      meta: {
        title: "菜单1",
        roles: ["admin", "common"],
      },
    },
    {
      path: "/listIn2",
      name: "listIn2",
      meta: {
        title: "菜单2-amin",
        roles: ["admin"],
      },
    },
    {
      path: "/listIn3",
      name: "listIn3",
      meta: {
        title: "菜单3",
        roles: ["admin", "common"],
      },
      children: [
        {
          path: "/listIn3-1",
          name: "/listIn3-1",
          meta: {
            title: "菜单3-1",
            roles: ["admin", "common"],
          },
          children: [
            {
              path: "/listIn3-1-1",
              name: "listIn3-1-1",
              meta: {
                title: "菜单3-1-1",
                roles: ["admin"],
              },
            },
            {
              path: "/listIn3-1-2",
              name: "listIn3-1-2",
              meta: {
                title: "菜单3-1-2",
                roles: ["admin", "common"],
              },
            },
          ],
        },
        {
          path: "/listIn3-2",
          name: "/listIn3-2",
          meta: {
            title: "菜单3-2",
            roles: ["admin", "common"],
          },
        },
      ],
    },
  ],
};

export default defineFakeRoute([
  {
    url: "/get-async-routes",
    method: "get",
    response: () => {
      return {
        success: true,
        data: [permissionRouter, componentsRouter,moreMenus],
      };
    },
  },
]);
